package com.jlpay.openapi.demo.cashier;

import com.jlpay.open.jlpay.sdk.java.model.cashier.request.PreOrderRequest;
import com.jlpay.open.jlpay.sdk.java.model.cashier.response.PreOrderResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/24
 **/
public class PreOrderService {
    private static final Logger LOGGER = LoggerFactory.getLogger(PreOrderService.class);

    public static void main(String[] args) {
        PreOrderRequest preOrderRequest = buildPreOrderRequest();
        PreOrderResponse preOrderResponse = JlpayOpenApiService.openMerchService()
                .post(preOrderRequest, PreOrderResponse.class);
        LOGGER.info("收银托管预下单响应:{}", JsonUtils.toString(preOrderResponse));
    }

    private static PreOrderRequest buildPreOrderRequest() {
        PreOrderRequest preOrderRequest = new PreOrderRequest();

        preOrderRequest.setMerchNo("849584358120018");
        preOrderRequest.setTermNo("60131234");
        preOrderRequest.setOutTradeNo("ld201911023465529");
        preOrderRequest.setPaymentValidTime("10");
        preOrderRequest.setDescription("充值中心-会员充值");
        preOrderRequest.setAttach("商城—-易拉宝10个打印纸20箱");
        preOrderRequest.setTotalAmount("1");
        preOrderRequest.setRemark("该订单物流请走顺丰快递");
        preOrderRequest.setNotifyUrl("https://help.jlpay.com/api/docs/home");
        preOrderRequest.setEnvVersion("release");
        preOrderRequest.setMerchAppid("wx336dcaf6a1ecf632");
        preOrderRequest.setReturnUrl("page/home/webview/webview?src=https%3A%2F%2Fmp.elong.com%2Ftenthousandaura%2F%3Factivitycode%3Dd32d7735-ae4f-440c-bb0c-dba4deba9470%26isSocket%3DHotelActivityId_8407&isRefresh=refresh&isSocket=HotelActivityId_8407**ecf632");

        return preOrderRequest;
    }
}
